﻿using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using System.Web.Http;
using WLYT.Application.Interfaces;
using WLYT.Domain.ApiModel;

namespace WLYT.Admin.WebApi.Controllers.Wms
{
    [AllowAnonymous]
    public class ILcktController : ApiController
    {
        private readonly IMaterialService MaterialService;
        private readonly ISupplierService SupplierService;
        private readonly IOrderService OrderService;
        public ILcktController(IOrderService orderService, IMaterialService materialService, ISupplierService supplierService)
        {
            OrderService = orderService;
            MaterialService = materialService;
            SupplierService = supplierService;
        }

        /// <summary>
        /// 物料同步
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
        [Route("api/Wms/ILckt/SyncMaterial")]
        public Task<ApiResult> SyncMaterial([FromBody] List<MaterialModel> model)
        {
            return MaterialService.SyncMaterial(model);
        }

        /// <summary>
        /// 供应商同步
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
        [Route("api/Wms/ILckt/SyncSupplier")]
        public Task<ApiResult> SyncSupplier([FromBody] List<SupplierModel> model)
        {
            return SupplierService.SyncSupplier(model);
        }

        /// <summary>
        /// 到货入库单新增/取消
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
        [Route("api/Wms/ILckt/SyncRKOrder")]
        public Task<ApiResult> SyncRKOrder([FromBody] OrderModel model)
        {
            return OrderService.SyncOrder(model);
        }

        /// <summary>
        /// 生产备料出库单新增/取消
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
        [Route("api/Wms/ILckt/SyncCKOrder")]
        public Task<ApiResult> SyncCKOrder([FromBody] OrderModel model)
        {
            return OrderService.SyncOrder(model);
        }

        /// <summary>
        /// 生产退料入库单新增/取消
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
        [Route("api/Wms/ILckt/SyncTLOrder")]
        public Task<ApiResult> SyncTLOrder([FromBody] OrderModel model)
        {
            return OrderService.SyncOrder(model);
        }
    }
}